package cn.jiekou.demo.webservice;

import cn.hutool.core.util.RandomUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import cn.hutool.log.StaticLog;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 李玄玄
 * @date 2025年04月01日 10:39
 */
@RestController
@RequestMapping(("/demo"))
public class DemoController {


    @RequestMapping("/query_funds")
    public String queryFunds() {
        List<Map<String, String>> list = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            Map<String, String> idMap = new HashMap<>();
            idMap.put("PSPID", RandomUtil.randomStringUpper(12));
            list.add(idMap);
        }

        Map<String, Object> jsonMap = new HashMap<>();
        jsonMap.put("OBJ_ID", "GET_KJXM");
        jsonMap.put("SYS_ID", "KJCX");
        jsonMap.put("DATA", list);


        // 封装请求参数
        String strParameter = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n" +
                "  <soapenv:Header/>" +
                "  <soapenv:Body>\n" +
                "    <urn:Zif93Interface>\n" +
                "  <IJson>" + JSONUtil.toJsonStr(jsonMap)
                + "</IJson>\n" +
                "    </urn:Zif93Interface>\n" +
                "   </soapenv:Body>\n" +
                " </soapenv:Envelope>";
        StaticLog.warn("查询经费信息入参为：" + strParameter);

        //HttpUtil.post("", strParameter);
        return strParameter;
    }
}
